﻿<UserControl x:Class="CapstoneProjectAEReader.GUIs.LibraryGUI.LocalLibrary"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:controls="http://schemas.taloware.com.au/wpf/controls" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <DataTemplate x:Key="bookListTemplate">
            <DockPanel Height="64" Background="Transparent">
                <Image Source="{Binding FileType}" Height="56" Width="56" Margin="4" HorizontalAlignment="Center" />
                <StackPanel Margin="4" HorizontalAlignment="Left">
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                        <Label Content="Title:" FontSize="12" FontWeight="SemiBold" Foreground="DarkRed" />
                        <Label Content="{Binding Title}" FontSize="12" FontWeight="Medium" Foreground="DarkRed" />
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                        <Label Content="Author:" FontSize="12" FontWeight="SemiBold" Foreground="Crimson" />
                        <Label Content="{Binding Author}" FontSize="12" FontWeight="Medium" Foreground="Crimson" />
                        <Label Content=" - " FontSize="12" FontWeight="SemiBold" />
                        <Label Content="Group: " FontSize="12" FontWeight="SemiBold" Foreground="DarkOrange" />
                        <Label Content="{Binding GroupInText}" FontSize="12" FontWeight="Medium" Foreground="Orange" />
                    </StackPanel>
                </StackPanel>
            </DockPanel>
        </DataTemplate>
        <DataTemplate x:Key="GroupItemTemplate">
            <StackPanel Orientation="Horizontal">
                <Image Source="{Binding FileType}" Margin="8,0,0,0" Height="10" Width="10" VerticalAlignment="Center" />
                <TextBlock Text="{Binding BookName}" FontSize="12" VerticalAlignment="Center" Margin="8,0,0,0" />
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="RecentReadTemplate">
            <StackPanel Orientation="Horizontal">
                <Image Source="{Binding FileType}" Height="32" Width="32" />
                <Label Content="{Binding Title}" />
            </StackPanel>
        </DataTemplate>
        <ContextMenu x:Key="RecentReadContextMenu">
            <MenuItem x:Name="ctRecentReadOpenEbook" Click="HandleDbMouseClickTvRecentRead" />
            <MenuItem x:Name="ctRecentReadRemoveItem" Click="HandleRemoveRecentReadItem" />
        </ContextMenu>
        <ContextMenu x:Key="GroupContextMenu">
            <MenuItem x:Name="ctGroupUpdate" Click="HandleEditEbookGroup" />
            <MenuItem x:Name="ctGroupDelete" Click="HandleDeleteEbookGroup" />
        </ContextMenu>
        <ContextMenu x:Key="EbookInGroupContextMenu">
            <MenuItem x:Name="ctOpenEbook" Click="HandleOpenEbookInGroup" />
            <MenuItem x:Name="ctRemoveEbook" Click="HandleRemoveEbookInGroup" />
        </ContextMenu>
    </UserControl.Resources>

    <Grid x:Name="LibraryGrid" Background="CornflowerBlue">
        <controls:DialogPresenter x:Name="listBoxDialogPresenter">
            <Grid Background="CornflowerBlue" Margin="10">
                <DockPanel>
                    <Label x:Name="lbLibraryForm" FontSize="20" Foreground="FloralWhite"
                           DockPanel.Dock="Top" />
                    <Grid Background="LightSkyBlue" Margin="8,8,8,2" DockPanel.Dock="Top">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="2*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <StackPanel Orientation="Horizontal" Grid.Column="0">
                            <Label x:Name="lbSearch" VerticalAlignment="Center" Height="30" FontWeight="SemiBold"
                                   HorizontalAlignment="Center" Margin="0" />
                            <TextBox HorizontalAlignment="Right" Height="24" Margin="8,2,8,2" TextWrapping="Wrap"
                                     x:Name="txtSearch" VerticalAlignment="Center" Width="250" />
                            <ComboBox x:Name="cbSearch" HorizontalAlignment="Center" VerticalAlignment="Center" Width="150"
                                      Height="24" Margin="10,2,10,2" />
                            <Button x:Name="btSearch" Background="Transparent" HorizontalAlignment="Center"
                                    Margin="10,2,2,2" VerticalAlignment="Center" BorderThickness="0" Click="HandleBtSearch">
                                <Image Source="Image/librarySearch.png" Height="20" />
                            </Button>
                        </StackPanel>
                    </Grid>

                    <Grid Margin="8,2,8,8" Height="auto" Width="auto">
                        <Grid.Background>
                            <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                <GradientStop Color="AliceBlue" Offset="0" />
                                <GradientStop Color="SkyBlue" Offset="1" />
                            </LinearGradientBrush>
                        </Grid.Background>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="6" />
                            <ColumnDefinition Width="2*" />
                        </Grid.ColumnDefinitions>

                        <DockPanel Margin="5" Grid.Column="2" x:Name="BookListRoot">
                            <Border BorderBrush="SkyBlue" BorderThickness="0,0,0,2" DockPanel.Dock="Top">
                                <Label x:Name="lbBookList" FontWeight="SemiBold" />
                            </Border>
                            <StackPanel Orientation="Horizontal" DockPanel.Dock="Bottom" HorizontalAlignment="Right">
                                <Button x:Name="btExportBook" Background="Transparent" BorderThickness="0" Margin="4"
                                        Click="HandleBtExportBook">
                                    <Grid>
                                        <Image Height="32" Width="168">
                                            <Image.Style>
                                                <Style TargetType="{x:Type Image}">
                                                    <Setter Property="Source" Value="Image/ButtonLarge.png" />
                                                    <Style.Triggers>
                                                        <DataTrigger
                                                            Binding="{Binding IsMouseOver, ElementName=btExportBook}" Value="True">
                                                            <Setter Property="Source"
                                                                    Value="Image/ButtonLargeHover.png" />
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </Image.Style>
                                        </Image>
                                        <Label x:Name="lbExportBook" HorizontalAlignment="Center"
                                               VerticalAlignment="Center" />
                                    </Grid>
                                </Button>
                                <Button x:Name="btAddBook" Background="Transparent" BorderThickness="0" Margin="4"
                                        Click="HandleBtAddBook">
                                    <Grid>
                                        <Image Height="32" Width="168">
                                            <Image.Style>
                                                <Style TargetType="{x:Type Image}">
                                                    <Setter Property="Source" Value="Image/ButtonLarge.png" />
                                                    <Style.Triggers>
                                                        <DataTrigger
                                                            Binding="{Binding IsMouseOver, ElementName=btAddBook}" Value="True">
                                                            <Setter Property="Source"
                                                                    Value="Image/ButtonLargeHover.png" />
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </Image.Style>
                                        </Image>
                                        <Label x:Name="lbAddBook" HorizontalAlignment="Center"
                                               VerticalAlignment="Center" />
                                    </Grid>
                                </Button>
                                <Button x:Name="btEditBook" Background="Transparent" BorderThickness="0" Margin="4"
                                        Click="HandleEditEbookDetail">
                                    <Grid>
                                        <Image Height="32" Width="168">
                                            <Image.Style>
                                                <Style TargetType="{x:Type Image}">
                                                    <Setter Property="Source" Value="Image/ButtonLarge.png" />
                                                    <Style.Triggers>
                                                        <DataTrigger
                                                            Binding="{Binding IsMouseOver, ElementName=btEditBook}" Value="True">
                                                            <Setter Property="Source"
                                                                    Value="Image/ButtonLargeHover.png" />
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </Image.Style>
                                        </Image>
                                        <Label x:Name="lbEditBook" HorizontalAlignment="Center"
                                               VerticalAlignment="Center" />
                                    </Grid>
                                </Button>
                                <Button x:Name="btDeleteBook" Background="Transparent" BorderThickness="0" Margin="4"
                                        Click="HandleBtDeleteEbook">
                                    <Grid>
                                        <Image Height="32" Width="168">
                                            <Image.Style>
                                                <Style TargetType="{x:Type Image}">
                                                    <Setter Property="Source" Value="Image/ButtonLarge.png" />
                                                    <Style.Triggers>
                                                        <DataTrigger
                                                            Binding="{Binding IsMouseOver, ElementName=btDeleteBook}" Value="True">
                                                            <Setter Property="Source"
                                                                    Value="Image/ButtonLargeHover.png" />
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </Image.Style>
                                        </Image>
                                        <Label x:Name="lbDeleteBook" HorizontalAlignment="Center"
                                               VerticalAlignment="Center" />
                                    </Grid>
                                </Button>
                            </StackPanel>

                            <ListView Name="listBook" ItemTemplate="{StaticResource bookListTemplate}" Margin="0,6,0,6"
                                      Background="Transparent" BorderThickness="0" DockPanel.Dock="Top" MouseDoubleClick="HandleDoubleClick">
                                <ListView.ItemContainerStyle>
                                    <Style TargetType="ListViewItem">
                                        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                                        <Setter Property="HorizontalAlignment" Value="Stretch" />
                                    </Style>
                                </ListView.ItemContainerStyle>
                            </ListView>
                        </DockPanel>
                        <Border BorderBrush="SkyBlue" BorderThickness="2" Margin="2,8,2,8" Grid.Column="1" />
                        <Grid Grid.Column="0" Margin="1">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <DockPanel Grid.Row="0">
                                <Border BorderBrush="SkyBlue" BorderThickness="0,0,0,2" DockPanel.Dock="Top" Margin="4">
                                    <Label x:Name="lbGroup" FontWeight="SemiBold" />
                                </Border>

                                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="4"
                                            DockPanel.Dock="Bottom">
                                    <Button x:Name="btAddGroup" Background="Transparent" BorderThickness="0" Margin="4"
                                            Click="HandleAddEbookGroup">
                                        <Grid>
                                            <Image Height="28" Width="123">
                                                <Image.Style>
                                                    <Style TargetType="{x:Type Image}">
                                                        <Setter Property="Source" Value="Image/Button.png" />
                                                        <Style.Triggers>
                                                            <DataTrigger
                                                                Binding="{Binding IsMouseOver, ElementName=btAddGroup}" Value="True">
                                                                <Setter Property="Source" Value="Image/ButtonHover.png" />
                                                            </DataTrigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </Image.Style>
                                            </Image>
                                            <Label x:Name="lbAddGroup" HorizontalAlignment="Center"
                                                   VerticalAlignment="Center" />
                                        </Grid>
                                    </Button>
                                    <Button x:Name="btEditGroup" Background="Transparent" BorderThickness="0" Margin="4"
                                            Click="HandleEditEbookGroup">
                                        <Grid>
                                            <Image Height="28" Width="123">
                                                <Image.Style>
                                                    <Style TargetType="{x:Type Image}">
                                                        <Setter Property="Source" Value="Image/Button.png" />
                                                        <Style.Triggers>
                                                            <DataTrigger
                                                                Binding="{Binding IsMouseOver, ElementName=btEditGroup}" Value="True">
                                                                <Setter Property="Source" Value="Image/ButtonHover.png" />
                                                            </DataTrigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </Image.Style>
                                            </Image>
                                            <Label x:Name="lbEditGroup" HorizontalAlignment="Center"
                                                   VerticalAlignment="Center" />
                                        </Grid>
                                    </Button>
                                    <Button x:Name="btDeleteGroup" Background="Transparent" BorderThickness="0" Margin="4"
                                            Click="HandleDeleteEbookGroup">
                                        <Grid>
                                            <Image Height="28" Width="123">
                                                <Image.Style>
                                                    <Style TargetType="{x:Type Image}">
                                                        <Setter Property="Source" Value="Image/Button.png" />
                                                        <Style.Triggers>
                                                            <DataTrigger
                                                                Binding="{Binding IsMouseOver, ElementName=btDeleteGroup}" Value="True">
                                                                <Setter Property="Source" Value="Image/ButtonHover.png" />
                                                            </DataTrigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </Image.Style>
                                            </Image>
                                            <Label x:Name="lbDeleteGroup" HorizontalAlignment="Center"
                                                   VerticalAlignment="Center" />
                                        </Grid>
                                    </Button>
                                </StackPanel>

                                <TreeView x:Name="GroupTreeView" Margin="4" Background="Transparent" BorderThickness="0"
                                          DockPanel.Dock="Top" MouseDoubleClick="HandleDoubleClickGroup" SelectedItemChanged="HandleGroupClick"
                                          ContextMenu="{StaticResource GroupContextMenu}">
                                </TreeView>
                            </DockPanel>

                            <DockPanel Grid.Row="1">
                                <Border BorderBrush="SkyBlue" BorderThickness="0,0,0,2" DockPanel.Dock="Top" Margin="4">
                                    <Label x:Name="lbRecentRead" FontWeight="SemiBold" />
                                </Border>

                                <TreeView x:Name="tvRecentRead" Margin="4" Background="Transparent" BorderThickness="0"
                                          DockPanel.Dock="Top" ItemTemplate="{StaticResource RecentReadTemplate}"
                                          MouseDoubleClick="HandleDbMouseClickTvRecentRead" ContextMenu="{StaticResource RecentReadContextMenu}">
                                </TreeView>
                            </DockPanel>
                        </Grid>
                    </Grid>
                </DockPanel>

            </Grid>
        </controls:DialogPresenter>
    </Grid>
</UserControl>